﻿/**
 * @author sminutoli
 * version 1.0
 * relaciona 
 */
import com.dinmax.flash.utilities.date.DateUtils
import com.dinmax.flash.central.bridge.CENTRALBridge

class com.dinmax.flash.central.bridge.MESSAGEDetailBridge
extends MovieClip {
	
	private var mcNote:MovieClip;
	private var mcClose:MovieClip;
	private var mcBack:MovieClip;
	private var mcSend:MovieClip;
	private var txt_date:TextField;
	private var txt_subject:TextField;
	private var txt_from:TextField;
	private var txt_body:TextField;
	
	private var listener:Object;
	private var value:Object;
	
	public function MESSAGEDetailBridge() {
		//trace("new MESSAGEDetailBridge()");
		var root:MESSAGEDetailBridge = this;
		mcClose.onPress= function():Void {
			root.listener.closeDisplay(root.value);
			return;
		};
		mcBack.onPress= function():Void {
			root.listener.closeDisplay();
			return;
		};
		mcSend.onPress= function():Void {
			CENTRALBridge.getActive().writeMessage(Number(root.txt_from.text));
			return;
		};
		
	}
	
	public function display(time, from, subject, body):Void{
		this.setDate(DateUtils.dateToString(time, DateUtils.date_DD_MM_AA, "-"));
		this.setFrom(from);
		this.setSubject(subject);
		this.setBody(body);
		return;
	};
	
	public function setDate(date:String):Void {
		txt_date.text = date;
		return;
	};
	
	public function setFrom(from:String):Void {
		txt_from.text = from;
		return;
	};
	
	public function setSubject(subject:String):Void {
		txt_subject.text = subject;
		return;
	};
	
	public function setBody(body:String):Void {
		txt_body.text = body;
		return;
	};
	
	public function setListener(listener:Object):Void {
		this.listener = listener;
		return;
	}
	public function setValue(value:Object):Void {
		this.value = value;
		return;
	}

}